package com.cn.cs;

import java.sql.*;

//选择
public class dome4 {
    public static void main(String[] args) {
//        update()
//        delete();

        try {
            //加载驱动jar
            Class.forName("com.mysql.jdbc.Driver");
            //获取链接
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql1","root","root");
            //获取发送sql的对象
            PreparedStatement pst =con.prepareStatement("select * from bbb");
            //执行sql获取结果数据
            ResultSet rs =pst.executeQuery();
            //遍历结果集
            while(rs.next()){
                System.out.println("编号:"+rs.getInt("id")+"\t姓名:"+rs.getString("name")+"\t性别:"+rs.getString("sex")+"\t年龄:"+rs.getInt("age"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
